package contest1610;

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class B {
    public static void main(String[] args) {
        Map<String, Integer> map = new TreeMap<>();
        System.out.println(map);
        Scanner cin = new Scanner(System.in);
        while (cin.hasNext()) {
            String word = cin.next();
            if (map.containsKey(word)) {
                map.put(word, map.get(word) + 1);
            } else {
                map.put(word, 1);
            }
        }
        System.out.println(map);
        for (String word : map.keySet()) {
            System.out.println(word + " " + map.get(word));
        }
    }
}
